package com.gaoxiang.humidity.controller;


import com.gaoxiang.humidity.dao.HumidityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/aaa")
public class HumidityController {


    KalmanFilter kalmanFilter = new KalmanFilter();

    @Autowired
    HumidityMapper humidityMapper;
    @GetMapping("/bbb")
    public List<Integer> humidity(){
        List<Integer> list = new ArrayList();
        list = humidityMapper.select();

        kalmanFilter.initial();
        int oldvalue = list.get(0);
        ArrayList<Integer> alist = new ArrayList<Integer>();
        for(int i = 0; i < list.size(); i++){
            int value = list.get(i);
            oldvalue = kalmanFilter.KalmanFilter(oldvalue,value);
            alist.add(oldvalue);
        }

        System.out.println(list);
        System.out.println(alist);

        return alist;


    }



}
